Skip to content

web: Clear stale submitted prompts on session reload#50

Merged
cgwalters merged 2 commits into
cgwalters:mainfrom
arewm:prompt-stickiness
Apr 8, 2026
Merged

web: Clear stale submitted prompts on session reload#50
cgwalters merged 2 commits into
cgwalters:mainfrom
arewm:prompt-stickiness

Conversation

@arewm

@arewm arewm commented Apr 7, 2026

Copy link
Copy Markdown
Collaborator

Devaipod hosts the OpenCode web UI in an iframe that is destroyed when the user switches to a different pod. If the switch happens while the agent is still processing, the per-session prompt state persisted in localStorage may retain the already-submitted text. When the user returns and the iframe is recreated, the stale prompt reappears in the input box.

This is specific to devaipod's iframe-based pod switching -- upstream OpenCode does not encounter this because the page is not torn down mid-processing. The workaround lives in the vendored UI code for now because that is where the per-session prompt persistence lives.

Extract isStaleSubmittedPrompt() into helpers.ts as a pure function: on session mount, if the session is idle, the prompt has content, and that content matches the last user message text, treat it as leftover from a prior submission and clear it. Legitimate unsent drafts are preserved because they won't match any sent message.

Assisted-by: OpenCode (claude-opus-4-6)

Devaipod hosts the OpenCode web UI in an iframe that is destroyed when
the user switches to a different pod.  If the switch happens while the
agent is still processing, the per-session prompt state persisted in
localStorage may retain the already-submitted text.  When the user
returns and the iframe is recreated, the stale prompt reappears in the
input box.

This is specific to devaipod's iframe-based pod switching -- upstream
OpenCode does not encounter this because the page is not torn down
mid-processing.  The workaround lives in the vendored UI code for now
because that is where the per-session prompt persistence lives.

Extract isStaleSubmittedPrompt() into helpers.ts as a pure function:
on session mount, if the session is idle, the prompt has content, and
that content matches the last user message text, treat it as leftover
from a prior submission and clear it.  Legitimate unsent drafts are
preserved because they won't match any sent message.

Assisted-by: OpenCode (claude-opus-4-6)
Signed-off-by: arewm <arewm@users.noreply.github.com>
@arewm arewm force-pushed the prompt-stickiness branch from 1431933 to dc0b42f Compare April 7, 2026 20:37
The agent health check uses `nc -z` in the workspace container to
detect whether the opencode server is listening. When a custom image
is used that lacks netcat (e.g. the devaipod image itself), every
poll silently fails, the 60-second timeout fires, and the initial
task message is never sent — leaving the agent idle with zero
sessions despite being healthy.

Fall back to `curl` when `nc` is unavailable, since curl is present
in a wider range of images.

Assisted-by: Claude Code (Opus 4.6)
Signed-off-by: arewm <arewm@users.noreply.github.com>
@arewm arewm force-pushed the prompt-stickiness branch from 0b68e44 to e6d4fed Compare April 8, 2026 01:03
@arewm arewm marked this pull request as ready for review April 8, 2026 12:35
@arewm

arewm commented Apr 8, 2026

Copy link
Copy Markdown
Collaborator Author

@cgwalters, I know that this is a patch on the vendored opencode code, but I am proposing this because it is more of an issue with our use of opencode than it is with opencode itself -- I don't know if we are using opencode as they intended.

@cgwalters cgwalters left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, makes sense. Bigger picture...what I'm thinking here is we may need to head towards a more custom frontend using agent-client-protocol.

@cgwalters cgwalters merged commit 8b99e51 into cgwalters:main Apr 8, 2026
3 checks passed
@arewm

arewm commented Apr 8, 2026

Copy link
Copy Markdown
Collaborator Author

I proposed something in #52 . I am going to kick off an implementation of the first couple phases of that to see how it looks.

@arewm arewm deleted the prompt-stickiness branch April 8, 2026 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants